import unittest
from CalcTools import started_queue
from Entity import StartedTask




class TestStartedTaskQueue(unittest.TestCase):

    def test_append_task(self):

        # 创建一个任务对象
        start_time_str1 = "2023-05-01 09:06:00"
        end_time_str1 = "2023-05-01 09:08:00"
        task1 = StartedTask(start_time_str1, end_time_str1, user_id=1, task_id=1, description="Task 1",
                           category="Work", priority=1, during=2)

        # 在任务队列中添加任务
        started_queue.append_task(task1)

        # 断言队列中包含了添加的任务
        self.assertIn(task1, started_queue.started_tasks)



    def test_clear_queue(self):
        start_time_str2 = "2023-05-01 09:06:00"
        end_time_str2 = "2023-05-01 09:10:00"
        task2 = StartedTask(start_time_str2, end_time_str2, user_id=1, task_id=2, description="Task 2",
                            category="Dajiao", priority=1, during=4)

        # 在任务队列中添加任务
        started_queue.append_task(task2)
        self.assertEqual(len(started_queue.started_tasks), 2)

        # 调用 clear_queue 方法清空队列
        started_queue.clear_queue()

        # 断言队列现在为空
        self.assertEqual(len(started_queue.started_tasks), 0)



if __name__ == '__main__':
    unittest.main()
